//
//  ViewController.m
//  签到
//
//  Created by Burn on 2018/12/13.
//  Copyright © 2018 nmgxysh. All rights reserved.
//

#import "ViewController.h"
#import "SiginTodayController.h"
#import "HeaderView.h"
#import "NSString+Base.h"
#import "PathView.h"

@interface ViewController ()

/***/
@property(strong,nonatomic) CAShapeLayer *cashapeLayer;

/***/
@property(strong,nonatomic) UIBezierPath *bzPath;

/***/
@property(strong,nonatomic) UIView *viewA;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    NSString *title = @"";
//    NSString *currentTime = [NSString getCurrentTimes];
//    NSArray *array = [currentTime componentsSeparatedByString:@"-"];
//    title = [title stringByAppendingString:array[0]];
//    title = [title stringByAppendingString:@"年"];
//    title = [title stringByAppendingString:array[1]];
//    title = [title stringByAppendingString:@"月"];
//
//
//
//    HeaderView *header = [[HeaderView alloc]initWithFrame:CGRectMake(0, 200, [UIScreen mainScreen].bounds.size.width, 100)];
//    [self.view addSubview:header];
//
//
//    NSString *formatterString = @"";
//    NSArray *timeArr = [currentTime componentsSeparatedByString:@" "];
//    NSArray *dayArray = [timeArr[0] componentsSeparatedByString:@"-"];
//
//    formatterString = [formatterString stringByAppendingString:dayArray[0]];
//    formatterString = [formatterString stringByAppendingString:@"-"];
//    formatterString = [formatterString stringByAppendingString:dayArray[1]];
//    formatterString = [formatterString stringByAppendingString:@"-"];
//    formatterString = [formatterString stringByAppendingString:@"01"];
//
//    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
//    formatter.dateFormat = @"yyyy-MM-dd";
//
//
//    NSLog(@"%@",[NSString getCurrentTimes]);
    
    
    self.viewA = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 20, 20)];
    self.viewA.backgroundColor = [UIColor darkGrayColor];
    self.cashapeLayer.path = self.bzPath.CGPath;
    [self.viewA.layer addSublayer:self.cashapeLayer];
    [self.view addSubview:self.viewA];
    


}

- (IBAction)value:(UISlider *)sender {
    self.cashapeLayer.strokeEnd = sender.value;
}

//- (NSInteger)getWeekday:(NSDate *)date {
//    /*1 = 周日 2 = 周一 .... 7 = 周六*/
//    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
//    NSDateComponents *comps = [[NSDateComponents alloc] init];
//    NSInteger unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitWeekday |
//    NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
//    // 话说在真机上需要设置区域，才能正确获取本地日期，天朝代码:zh_CN
//    calendar.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
//    comps = [calendar components:unitFlags fromDate:date];
//    return [comps weekday];
//}


- (CAShapeLayer *)cashapeLayer{
    if (!_cashapeLayer) {
        _cashapeLayer = [CAShapeLayer layer];
        _cashapeLayer.frame = self.viewA.bounds;
        _cashapeLayer.lineWidth = 5;
        _cashapeLayer.fillColor = [UIColor orangeColor].CGColor;
        _cashapeLayer.strokeEnd = 0;
    }
    return _cashapeLayer;
}

- (UIBezierPath *)bzPath{
    if (!_bzPath) {
        _bzPath = [UIBezierPath bezierPathWithRoundedRect:self.viewA.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(10, 10)];
        
    }
    return _bzPath;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    SiginTodayController *vc = [[SiginTodayController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
    
//    CABasicAnimation *base = [CABasicAnimation animation];
//    base.keyPath = @"transform.scale";
//    base.toValue = [NSNumber numberWithFloat:1.2];
//    [self.cashapeLayer addAnimation:base forKey:nil];
    
    
}


@end
